local component = require("component")
local computer = require("computer")
local internet = require("internet")

local function gitee_get(url)
    local r, response = pcall(internet.request, url, nil, { ["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" })
    if not r then
		print("没网卡装你妈呢？")
		return ""
	end
	local a = ""
    for chunk in response do a = a..chunk end
    return a
end

local function writeRom(bios, label)
	local eeprom = component.eeprom
	io.write("正在覆写BIOS，不要关机")
	eeprom.set(bios)
	eeprom.setLabel(label)
end

io.write("下载BIOS")
local res = gitee_get("https://gitee.com/jvn/MineOS-Mirror/raw/master/Installer/BIOS.lua")

if res == "" then
    print("安装取消")
    return
end

writeRom(res, "MineOSInstaller")

io.write("正在重启")
os.sleep(1)
computer.shutdown(true)




